<?php
/**
 * Created by PhpStorm.
 * User: Pico_Dragon
 * Date: 15/12/2014
 * Time: 04:28
 */
include "../../db/dbConnect.php";
error_reporting(E_ALL && ~ E_NOTICE);
if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['idu']) {

    $sql="select active from u_user where iduser='".$_POST['idu']."'";
    $result=mysql_query($sql);
    if(mysql_error()){
        echo mysql_error();
        exit();
    }
    $row=mysql_fetch_array($result);
    $active=$row['active'];
    $row['active']=($row['active'] ==1)?0:1;

    $sql="update u_user set active=".$row['active']." where iduser=".$_POST['idu'];
    if(mysql_query($sql)){
        if($active==1){
            echo "Đã khóa tài khoản ";
        }else
            echo "Đã kích hoạt tài khoản ";

    }else{
        echo mysql_error();exit();
    }
}else echo "buzz";
?>